import {apiUsername,apiPassword} from "@/settings.js";
import {commonLogin} from '@/api/login.js'
const user = apiUsername;
const pass = apiPassword;

export default function(){
	return new Promise(resolve => {
		var token = uni.getStorageSync('token');
		if(token){
			resolve(token);
		}else{
			commonLogin('api',{
				username: user,
				password: pass,
			}).then(res=>{
				console.log('获取token', res)
				if(res.data.code == 200){
					uni.setStorageSync('token', res.data.token);
				}
				resolve(res.data.token);
			})
		}
	});
}